<script>
	// const base_url_dev = 'https://dcxt.swdxf.cn/order-api-test'
	const base_url_dev = 'https://dcxt.swdxf.cn/order-api'
	// const base_url_dev = 'http://172.16.46.54:8001/order-api'	
	// const base_url_dev = 'http://172.32.200.167:10086'
	// const base_url_dev = 'http://172.16.76.56:10086'
	const base_url_prod = 'https://dcxt.swdxf.cn/order-api'
	import {
		login
	} from '@/api/user.js'
	import {
		categoryQueryAll,
		getBannerList
	} from '@/api/common.js'
	export default {
		globalData: {
			foodsList: [],
			baseUrl: '',
			code: '',
			openId: '',
			orderDetail: null,
			user: null,
			hasLogin: false,
			baseImgurl: '',
			templateId: ['SgCCNbq9rnchEhHtMVvlczrc89xcpoVoA9RRcZ7f9ZU', 'HMVoz25c5nkhTO7R-_UZ-kKXhUng57WK94M9tFhpOTs'],
			addMealOrderDeatil: null,
			count: 0,
			windowHeight: 0,
			bannerList: []
		},
		onLaunch: function() {


			let res = uni.getSystemInfoSync()
			this.globalData.windowHeight = res.windowHeight

			const updateManager = uni.getUpdateManager()

			updateManager.onCheckForUpdate(function(res) {
				console.log("更新情况", res)
			})

			updateManager.onUpdateReady(function(res) {
				updateManager.applyUpdate();
			})

			let that = this
			if (process.env.NODE_ENV === 'development') {
				this.globalData.baseUrl = base_url_dev
				// this.globalData.baseImgurl = 'http://127.0.0.1:10085/upload/'
				this.globalData.baseImgurl = 'http://dcxt.swdxf.cn/upload/'
				// this.globalData.baseImgurl = 'http://172.16.46.54:8001/upload/'
				// this.globalData.baseImgurl = 'https://xzwxzw.oss-cn-hangzhou.aliyuncs.com/005cda5c-f4d6-4b33-8608-926cd62c1c09.jpg'
			} else {
				this.globalData.baseUrl = base_url_prod
				this.globalData.baseImgurl = 'https://dcxt.swdxf.cn/upload/'
			}

			getBannerList(this.globalData.baseUrl).then(res => {
				that.globalData.bannerList = res.data.map(item => {
					return that.globalData.baseImgurl + '/' + item
				})
			}).catch(res=>{
				console.log(res)
			})

			uni.login({
				provider: 'weixin',
				success: function(loginRes) {
					login(loginRes.code).then(res => {
						console.log("获取OpenID", loginRes)
						if (res.code === 19999) {
							that.globalData.openId = res.data
							that.globalData.hasLogin = false
						}
						if (res.code === 20000) {
							that.globalData.user = res.data
							that.globalData.openId = res.data.openid
							that.globalData.hasLogin = true
						}

					}).catch(res => {
						console.log(res)
					})
				}
			});
		},
		onShow: function() {
			// console.log('App Show')
		},
		onHide: function() {
			// console.log('App Hide')
		}
	}
</script>
<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "uview-ui/index.scss";
</style>
<style>
	/*每个页面公共css */
</style>
